package app.beit.fintrack.ws.dc.client;

import java.net.MalformedURLException;
import java.net.URL;

import app.beit.fintrack.ws.dc.AuthenResultDto;
import app.beit.fintrack.ws.dc.UCDCAuthenService;
import app.beit.fintrack.ws.dc.UCDCAuthenService_Service;

public class DCWebserviceClient {
	
	private static UCDCAuthenService ucdcAuthen;

	public DCWebserviceClient(final String wsdlPath) {
		try {
		      
	        UCDCAuthenService_Service ss = new UCDCAuthenService_Service(new URL(wsdlPath));
	        ucdcAuthen = ss.getUCDCAuthenInfPort();  
		} catch (MalformedURLException e) {
			e.printStackTrace();
		}
	}

	public UCDCAuthenService getUcdcAuthen() {
		return ucdcAuthen;
	}
	
	//For test
	public static void main(String[] args){
		DCWebserviceClient dc = new DCWebserviceClient("http://ucdcws.nhso.go.th/UCDCWS/authenService?wsdl");
		UCDCAuthenService service = dc.getUcdcAuthen();
		//TODO Test
//		AuthenResultDto dto = service.getUserWithPermissions("5813418178283", "fintrack1234", "11111");
//		AuthenResultDto dto = service.getUser("5813418178283", "fintrack1234");
		AuthenResultDto dto = service.getUserWithPermissions("550001162210", "fintrack1234", "55");
		System.err.println(dto.getErrorMessage());
	}

}
